package suzf.top.goodscenter.presenter

import suzf.top.base.ext.execute
import suzf.top.base.presenter.BasePresenter
import suzf.top.base.rx.BaseSubscriber
import suzf.top.goodscenter.data.protocol.Category
import suzf.top.goodscenter.presenter.view.CategoryView
import suzf.top.goodscenter.service.CategoryService
import javax.inject.Inject

/**
 *
 *========================
 * Created with AndroidStudio
 * Author:Mr.Su
 * Date:2019-09-07
 * Time:20:56
 * ========================
 */
class CategoryPresenter @Inject constructor() : BasePresenter<CategoryView>() {

    @Inject
    lateinit var categoryService: CategoryService

    fun getCategory(parentId: Int) {
        /**
        业务逻辑处理
         */
        if (!checkNetWork()) {
            return
        }
        mView.showLoading()
        categoryService.getCategory(parentId)
                .execute(object: BaseSubscriber<MutableList<Category>?>(mView) {
                    override fun onNext(t: MutableList<Category>?) {
                        mView.onGetCategoryResult(t)
                    }
                }, lifecycleProvider)

    }

}